package com.demo.models;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

public class News extends Model<News> {

	public static List<String> cateList = new ArrayList<String>();
	public static final News me = new News();
	
	public void init() {
		List<News> list = me.find("select DISTINCT cate_name from article");
		for (News news : list) {
			cateList.add(news.getStr("cate_name"));
		}
		System.out.println(list.size() + " cateName init.");
	}
	
	public Page<News> paginate(String cate, int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from article where cate_name=? order by id asc", cate);
	}
	public Page<News> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from article order by id asc");
	}
}
